package com.polaris.live.im.db.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey

/**
 * 充值消费订单缓存
 *
 * @author Created by lucas on 2023/11/22 19:15
 * @since 1.0.0
 */
@Entity(
    tableName = "purchase_order",
    indices = [
        Index(value = ["user_id"]),
        Index(value = ["purchase_token"], unique = true)
    ]
)
data class PurchaseOrderEntity(
    /**
     * 数据库主键
     */
    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "table_id")
    val tableId: Int? = null,
    /**
     * 所属的用户
     */
    @ColumnInfo(name = "user_id")
    val userId: Long,
    /**
     * 包名
     */
    @ColumnInfo(name = "package_name")
    val packageName: String,
    /**
     * 价格id
     */
    @ColumnInfo(name = "product_id")
    val productId: String,
    /**
     * 用于标识此购买交易的购买令牌
     */
    @ColumnInfo(name = "purchase_token")
    val purchaseToken: String,
    /**
     * 购买商品的时间，以从公元纪年（1970 年 1 月 1 日）开始计算的毫秒数表示。
     */
    @ColumnInfo(name = "purchase_time")
    val purchaseTime: Long,
    /**
     * 订单的购买状态。可能的值包括：0。购买 1. 已取消 2. 待处理
     */
    @ColumnInfo(name = "purchase_state")
    val purchaseState: Int,
    /**
     * 与购买应用内商品相关的订单 ID。
     */
    @ColumnInfo(name = "order_id")
    val orderId: String? = null,
    /**
     * 服务端生成的token
     */
    @ColumnInfo(name = "token")
    val token: String? = null,
    /**
     * 创建时间
     */
    @ColumnInfo(name = "timestamp")
    val timestamp: Long
)